<?php
/**
 * Created by PhpStorm.
 * User: XP
 * Date: 2017/11/9
 * Time: 19:31
 */
namespace app\index\controller;
use \think\Session;
class Pre extends \think\Controller
{
    //显示用户界面
    public function preview()
    {
        $level = Session::get('user');
        if (!empty($level)) {
            $this->assign('username', $level->name);
            $this->assign('userlevel', $level->level);
            if ($level->getLevel() == 0) {
                $this->redirect('/index/Adm/admin');
            } else if($level->getLevel() == 1){
                $this->redirect('/index/Sta/staff');
            }else{
                return $this->fetch();
            }
        } else {
            $this->redirect('/');
        }
    }
    public function userExit(){
        Session::clear();
        return Session::has('user');
    }
}
